﻿using System;
using System.IO;
using System.Xml.Serialization;

namespace _034_自定义XML命名空间
{
    class Program
    {
        static void Main(string[] args)
        {
            using (MemoryStream 内存流=new MemoryStream())
            {
                序列化测试 vt = new 序列化测试
                {
                    Value1 = 96,
                    Value2 = "发可松狮好"
                };
                XmlSerializer 神你好 = new XmlSerializer(vt.GetType());
                神你好.Serialize(内存流, vt);

                内存流.Position = 0L;
                using (StreamReader 文件强=new StreamReader(内存流))
                {
                    string 文件终极 = 文件强.ReadToEnd();
                    Console.WriteLine($"序列化后生成的XML文档：\n{文件终极}");
                }
            }

            Console.Read();

        }
    }

    [XmlRoot(Namespace ="z01.com")]
    public class 序列化测试
    {
        [XmlElement(Namespace ="test.org/prop")]
        public int Value1 { get; set; }
        [XmlElement(Namespace ="test.org/prop")]
        public string Value2 { get; set; }
    }
}
